<?php
include('../incsession.php');
include("timer.php");



?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>sample page</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen">

<script type="text/javascript" src="drag.js"></script>
<script type="text/javascript">
	function init(){
		REDIPS.drag.init();
		REDIPS.drag.drop_option = "switch";
		REDIPS.drag.trash_ask = false;
		//REDIPS.drag.clone_ctrlKey = true;
		REDIPS.drag.myhandler_dropped = function(){
			
			document.dnd.dnd_result.value =REDIPS.drag.save_content(0); 	
		}
	}
</script>
<style type="text/css">
#table1{
	width:520px;	
}
#drag{
	width:970px;
}
.drag{
	width:430px !important;
	width:440px;
}
#main_container{
	width: 970px;
}
		/* container for the left table */
		#main_container #left{
			width: 520px;
		}
		#main_container #right{
			width: 440px;
		}
</style>
</head>

<body onLoad="TimeCountDown(),init()">
<div id="wrapper">
	<div id="header">
		<div id="logo"></div>
		<div id="menu">
        <?php
			include("menu.php");
		?>
       
		</div>
	</div>
	<div class="clearer"></div>
	<div class="edge-top"></div>

	<div id="main">

		<div id="title">大綱練習<font size=4><br>請將右邊選項和左邊的題目敘述配對，將選項拖曳至中間的灰色區域中</font></div>
<hr/><br><br>

<!-- 內文開始 !-->
<form name="dnd" method = "POST" action="abstract_dnd_answers.php" >
<div id="main_container">
<div id="drag">
<?php
	$tid = $_SESSION['topic'];
	$level = $_SESSION['level'];

	$sql = "SELECT * FROM `abstract_drag_and_drop` WHERE `topicid` = '".$tid."' AND `level` = '".$level."' ORDER BY `layer`";
	$result = mysql_query($sql, $orcp_con);
	$question_num = mysql_num_rows($result);
	
	echo "<div id='left'>\n";
	echo "<table id='table1'>\n";
	echo "<colgroup><col width='80'/><col width='440'/></colgroup>\n";
	echo "<tr  style='background-color: #FFF'><td>題目敘述<td>你的答案";
	for($i=0;$i<$question_num;$i++)
		$question[$i] = mysql_fetch_row($result);

	$num1=0;
	for($i=0;$i<$question_num;$i++)
	{
		if($question[$i][2]==10000){
			$num1++;
			//echo "<tr class='upper'><td  style='background-color: #ADDFFF'><font size=4pt>".$question[$i][1]."</font></td>\n";
			echo "<tr class='upper'><td  style='background-color: #ADDFFF'><font size=4pt>".$num1."</font></td>\n";
			$num2[$num1]=0;
		}
		if((int)($question[$i][2]/10000)!=1 && (int)($question[$i][2]/10000)!=(int)($question[$i-1][2]/10000)){
			$num1++;
			//echo "<tr class='upper'><td  style='background-color: #ADDFFF'><font size=4pt>".$question[$i][1]."</font></td>\n";
			echo "<tr class='upper'><td  style='background-color: #ADDFFF'><font size=4pt>".$num1."</font></td>\n";	
			$num2[$num1]=0;
		}
		else if($question[$i][2]!=10000 && (int)($question[$i][2]/10000)==(int)($question[$i-1][2]/10000)){		
			if((int)($question[$i][2]/100)!=1 && (int)($question[$i][2]/100)!=(int)($question[$i-1][2]/100)){
				$num2[$num1]++;
				//echo "<tr><td style='background-color: #BDEDFF'><font size=4pt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$question[$i][1]."</font></td>\n";
				echo "<tr><td style='background-color: #BDEDFF'><font size=4pt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$num1."-".$num2[$num1]."</font></td>\n";
				$num3[$num1][$num2[$num1]]=0;
			}else{
				$num3[$num1][$num2[$num1]]++;
				//echo "<tr><td style='background-color: #E0FFFF'><font size=3pt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$question[$i][1]."</font></td>\n";
				echo "<tr><td style='background-color: #E0FFFF'><font size=3pt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$num1."-".$num2[$num1]."-".$num3[$num1][$num2[$num1]]."</font></td>\n";
			}
		}
		$sql2 = "SELECT answer FROM `abstract_dnd_answer` WHERE layer = '".$question[$i][2]."'";
		$result2 = mysql_query($sql2, $orcp_con);
		$tmp = mysql_fetch_row($result2);
		if($tmp[0]=="")
			echo "<td class='mark'></td>\n";	
		else
			echo "<td></td>\n";
		echo "</tr>\n";
	}
	echo "</table>\n";
	echo "</div>\n";

	$sql = "SELECT * FROM `abstract_dnd_answer` WHERE `topicid` = '".$tid."' AND `level` = '".$level."' AND `answer` <> ''";
	$result = mysql_query($sql, $orcp_con);
	$answer_num = mysql_num_rows($result);
	echo "<div id='right'>";
	echo "<table id='table2'>";
	echo "<colgroup><col/></colgroup>";
	echo "<tr  style='background-color: #FFF; border-bottom: solid 20px #FFF'><td>選項";
	for($i=0;$i<$answer_num;$i++)
		$answer[$i] = mysql_fetch_row($result);
	for($i=0;$i<$answer_num;$i++)
	{
		$j = rand($i, $answer_num-1);
		$tmp = $answer[$i];
		$answer[$i] = $answer[$j];
		$answer[$j] = $tmp;
	}
	for($i=0;$i<$answer_num;$i++)
	{
		echo "<tr>\n";
		if($answer[$i][1] == "")
			echo "<td><div class='drag' id=".$answer[$i][0].">&nbsp;</div></td>\n";
		else
			echo "<td><div class='drag' id=".$answer[$i][0].">".$answer[$i][1]."</div></td>\n";
		echo "</tr>\n";
	}
	echo "</table>\n";
	echo "</div>\n";
?>



<input type="hidden" value="" name="dnd_result">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
</div>
<div class="btn_right"><input type="submit" name = "next" value = "下一步 >> 參考答案"></div>
</form>
<!-- 內文結束 !-->



	</div>
    <div class="edge-bottom"></div>
    <div id="footer"><?php  include("footer.php"); ?></div>
</div>

<div id="txt">18:27</div>



</body>
</html>

